<html>
<head><meta charset="utf-8"><title>Blog Post · project-ffi-unwind · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/index.html">project-ffi-unwind</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html">Blog Post</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="184148037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184148037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184148037">(Dec 24 2019 at 03:16)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I started drafting a blog post, but it's pretty far from finished. If you have time, you may be interested in taking a look and seeing if I'm heading in the right direction. <a href="https://github.com/BatmanAoD/project-ffi-unwind/blob/BlogPost-announcement/blogposts/inside-rust/01-announcement.md" target="_blank" title="https://github.com/BatmanAoD/project-ffi-unwind/blob/BlogPost-announcement/blogposts/inside-rust/01-announcement.md">https://github.com/BatmanAoD/project-ffi-unwind/blob/BlogPost-announcement/blogposts/inside-rust/01-announcement.md</a></p>



<a name="184674920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184674920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184674920">(Jan 02 2020 at 18:58)</a>:</h4>
<p>the post gives a lot of background, I'm wondering if it almost gives <em>too</em> much, but I'm not sure</p>



<a name="184674933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184674933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184674933">(Jan 02 2020 at 18:59)</a>:</h4>
<p>I might try an alternative outline just to see</p>



<a name="184674943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184674943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184674943">(Jan 02 2020 at 18:59)</a>:</h4>
<p>I wasn't planning on giving as much background as I ended up writing</p>



<a name="184674969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184674969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184674969">(Jan 02 2020 at 18:59)</a>:</h4>
<p>But as I went, I realized that I don't think we have one place that explains the background with a balance of detail &amp; brevity</p>



<a name="184687311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184687311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184687311">(Jan 02 2020 at 21:49)</a>:</h4>
<p>Yeah</p>



<a name="184687322"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184687322" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184687322">(Jan 02 2020 at 21:49)</a>:</h4>
<p>There does seem to be value in that</p>



<a name="184687933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184687933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184687933">(Jan 02 2020 at 21:58)</a>:</h4>
<p>Maybe we even want two blog posts</p>



<a name="184691629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184691629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184691629">(Jan 02 2020 at 23:04)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> this is WIP, but take a look at <a href="https://hackmd.io/PMlTBQS2T1i_a3lBW0348g?edit" target="_blank" title="https://hackmd.io/PMlTBQS2T1i_a3lBW0348g?edit">what I wrote so far</a>. I'm trying to capture the "essence" of the problem as I see it...</p>



<a name="184867259"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184867259" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184867259">(Jan 05 2020 at 22:06)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> One question on the blog post: the second alternative you describe is:</p>
<blockquote>
<p>Add a new ABI ("C unwind") that permits unwinding; the "C" ABI is specified as the system ABI but where unwinding is UB</p>
</blockquote>
<p>Since the original plan was for Rust functions defined with the "C" ABI to abort-on-panic, I had assumed that this would be the "default" option. Is this what you're referring to here, or would that be a third option?</p>



<a name="184867352"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184867352" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184867352">(Jan 05 2020 at 22:08)</a>:</h4>
<p>I.e., unwinding would only be UB coming from foreign functions (or perhaps from an improper use of <code>unsafe</code>, I suppose), since "C" ABI Rust functions could not otherwise expose unwinding.</p>



<a name="184873505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/184873505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#184873505">(Jan 06 2020 at 01:18)</a>:</h4>
<p>In any case, I have updated <a href="https://github.com/BatmanAoD/project-ffi-unwind/blob/BlogPost-announcement/blogposts/inside-rust/01-announcement.md" target="_blank" title="https://github.com/BatmanAoD/project-ffi-unwind/blob/BlogPost-announcement/blogposts/inside-rust/01-announcement.md">my draft</a> to incorporate a decent amount of the text from yours.</p>



<a name="185063756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063756">(Jan 07 2020 at 22:54)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@Kyle Strand</span> I believe the proposal was that unwinding through the "C" ABI was undefined behavior. Given that it is undefined, functions defined <em>in Rust</em> with the C ABI can abort -- but functions not defined in Rust would not abort</p>



<a name="185063757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063757">(Jan 07 2020 at 22:54)</a>:</h4>
<p>from the POV of the caller, you can be sure that unwinding never happens</p>



<a name="185063780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063780">(Jan 07 2020 at 22:54)</a>:</h4>
<p>and some callees (ones defined in Rust) guarantee that by aborting</p>



<a name="185063794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063794">(Jan 07 2020 at 22:55)</a>:</h4>
<p>I'm not sure if that is different from what you said :)</p>



<a name="185063812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063812">(Jan 07 2020 at 22:55)</a>:</h4>
<p>where is your updated blog post now..? in the PR?</p>



<a name="185063845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063845">(Jan 07 2020 at 22:56)</a>:</h4>
<p>I feel like my draft was still missing a certain amount of the arguments either way, but it was already useful in that I kind of shifted my opinion based on what <span class="user-mention" data-user-id="143274">@Amanieu</span> was pointing out</p>



<a name="185063889"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063889" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063889">(Jan 07 2020 at 22:56)</a>:</h4>
<p>I think I just didn't realize while reading the draft the first time how important it is to emphasize that even with the "abort-on-unwind" logic, there's still UB.</p>



<a name="185063899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063899">(Jan 07 2020 at 22:56)</a>:</h4>
<p>Yes, I've continued updating the PR</p>



<a name="185063914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063914">(Jan 07 2020 at 22:56)</a>:</h4>
<p>it seems like the plan if "UB if you unwind with <code>-Cpanic=abort</code>, but best effort aborts on debug" is the best option</p>



<a name="185063938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063938">(Jan 07 2020 at 22:57)</a>:</h4>
<p>one thing I was wondering about was whether other <code>-C</code> options could induce UB in this way</p>



<a name="185063949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063949">(Jan 07 2020 at 22:57)</a>:</h4>
<p>that's a good question...</p>



<a name="185063959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063959">(Jan 07 2020 at 22:57)</a>:</h4>
<p>I think you can <em>imagine</em> a world where <code>-Cpanic=abort</code> simply refuses to compile code with <code>"C unwind"</code> ABI, but I think that's not really tenable</p>



<a name="185063984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063984">(Jan 07 2020 at 22:57)</a>:</h4>
<p>I think the <code>longjmp</code> situation more or less precludes that, doesn't it?</p>



<a name="185063986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185063986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185063986">(Jan 07 2020 at 22:57)</a>:</h4>
<p>it's also very interesting that calls like <code>read</code> <em>may</em> unwind and may not, depending on the details of what platform you are on</p>



<a name="185064066"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064066" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064066">(Jan 07 2020 at 22:58)</a>:</h4>
<p>which means that if we try to separate out in the ABI, we have to either <em>overapproximate</em> (to use "C unwind") or vary by target ("ugh") or just rule out some details of pthread cancelation ("seems like losing capabilities")</p>



<a name="185064070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064070">(Jan 07 2020 at 22:58)</a>:</h4>
<p>since <code>longjmp</code> should "always work", even if it's using unwinding under the covers, and therefore the <code>"C"</code> ABI needs to never interfere with it</p>



<a name="185064102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064102">(Jan 07 2020 at 22:59)</a>:</h4>
<p>well I imagine that <code>-Ctarget-feature</code> can cause UB</p>



<a name="185064118"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064118" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064118">(Jan 07 2020 at 22:59)</a>:</h4>
<p>i.e., if your target actually lacks those features</p>



<a name="185064135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064135">(Jan 07 2020 at 22:59)</a>:</h4>
<p>similarly things like <code>link-args</code></p>



<a name="185064145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064145">(Jan 07 2020 at 22:59)</a>:</h4>
<p>who knows what <em>those</em> can do</p>



<a name="185064209"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064209" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064209">(Jan 07 2020 at 23:00)</a>:</h4>
<p>so it seems like <code>-C</code> is already "best know what you're doing" territory to me, even though we should try hard to remove rough edges where we can</p>



<a name="185064335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064335">(Jan 07 2020 at 23:02)</a>:</h4>
<blockquote>
<p>it seems like the plan if "UB if you unwind with <code>-Cpanic=abort</code>, but best effort aborts on debug" is the best option</p>
</blockquote>
<p>the good news about this is that it means <code>-Cpanic=abort</code> continues to be fully optimizable no matter what we choose</p>



<a name="185064588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185064588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185064588">(Jan 07 2020 at 23:05)</a>:</h4>
<p>which means metrics don't matter</p>



<a name="185065145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065145">(Jan 07 2020 at 23:12)</a>:</h4>
<p>The concerning thing about <code>-Cpanic=abort</code> to me is that even if <code>-C</code> "should" mean "best know what you're doing", I think <code>panic=abort</code> is probably not perceived that way.</p>



<a name="185065158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065158">(Jan 07 2020 at 23:13)</a>:</h4>
<p>Especially since it's exposed via Cargo</p>



<a name="185065240"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065240" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065240">(Jan 07 2020 at 23:14)</a>:</h4>
<p>Yes</p>



<a name="185065250"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065250" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065250">(Jan 07 2020 at 23:14)</a>:</h4>
<p>This is why I would definitely want "abort in debug mode"</p>



<a name="185065264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065264">(Jan 07 2020 at 23:14)</a>:</h4>
<p>I would even consider <code>panic=ub</code> or something</p>



<a name="185065267"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065267" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065267">(Jan 07 2020 at 23:14)</a>:</h4>
<p>(and make <code>abort</code> determinstically abort)</p>



<a name="185065299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065299">(Jan 07 2020 at 23:15)</a>:</h4>
<p>I think a big question is how much you care about <code>pthread_exit</code> and these interactions with <code>read</code> -- I'm trying to put my finger on it</p>



<a name="185065367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065367">(Jan 07 2020 at 23:16)</a>:</h4>
<p>Well....</p>



<a name="185065389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065389">(Jan 07 2020 at 23:16)</a>:</h4>
<p>Semantically, there's an argument, I think, that <code>panic=abort</code> "just" means exactly what it says: <code>panic!</code> will trigger an abort.</p>



<a name="185065420"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065420" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065420">(Jan 07 2020 at 23:17)</a>:</h4>
<p>To my mind, this means that leaving abort shims around in every  function that invokes a <code>"C"</code> function would be entirely permissible.</p>



<a name="185065485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065485">(Jan 07 2020 at 23:18)</a>:</h4>
<p>That would be a concrete difference between <code>panic=ub</code> and <code>panic=abort</code>, and I  think it would simplify the implementation of both quite a bit.</p>



<a name="185065505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065505">(Jan 07 2020 at 23:18)</a>:</h4>
<p>Although, come to think of it, going on that semantic argument, it shouldn't be <code>panic=ub</code>, it should be <code>panic=abort</code> _and_ <code>unwind=ub</code></p>



<a name="185065507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065507">(Jan 07 2020 at 23:18)</a>:</h4>
<p>so a new flag...</p>



<a name="185065607"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065607" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065607">(Jan 07 2020 at 23:20)</a>:</h4>
<blockquote>
<p>To my mind, this means that leaving abort shims around in every  function that invokes a <code>"C"</code> function would be entirely permissible.</p>
</blockquote>
<p>point is, that wouldn't permit invoking longjmp</p>



<a name="185065638"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065638" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065638">(Jan 07 2020 at 23:21)</a>:</h4>
<p>er, sorry</p>



<a name="185065653"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065653" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065653">(Jan 07 2020 at 23:21)</a>:</h4>
<p>longjmp would have to be given "C unwind", presumably, at least on some platforms</p>



<a name="185065666"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065666" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065666">(Jan 07 2020 at 23:21)</a>:</h4>
<p>I think maybe an appealing configuration would be something like this:</p>



<a name="185065727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065727">(Jan 07 2020 at 23:22)</a>:</h4>
<ul>
<li>with the "C" ABI, unwinding over a frame w/ dtors is UB (but unwinding is permitted otherwise)</li>
<li>with "C unwind", unwinding works, but it's an error to <em>invoke</em> such functions with <code>-Cpanic=abort</code></li>
</ul>



<a name="185065730"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065730" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065730">(Jan 07 2020 at 23:22)</a>:</h4>
<p>I'm not sure about that; the abort shims already permit <code>longjmp</code>.</p>



<a name="185065739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065739">(Jan 07 2020 at 23:22)</a>:</h4>
<p>basically, if you use foreign unwinding and rely on it to execute dtors, your ;library is just unusable with panic=abort</p>



<a name="185065753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065753">(Jan 07 2020 at 23:23)</a>:</h4>
<p>I don't think that _needs_ to be the case.</p>



<a name="185065771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065771">(Jan 07 2020 at 23:23)</a>:</h4>
<p>well, it kind of does, right?</p>



<a name="185065777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065777">(Jan 07 2020 at 23:23)</a>:</h4>
<p>it's true we could special-case longjmp</p>



<a name="185065778"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065778" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065778">(Jan 07 2020 at 23:23)</a>:</h4>
<p>Any form of "forced unwind" should never trigger an abort, I think.</p>



<a name="185065834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065834">(Jan 07 2020 at 23:24)</a>:</h4>
<p>well, it is not ok if you fail to run dtors,</p>



<a name="185065836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065836">(Jan 07 2020 at 23:24)</a>:</h4>
<p>Because the definition of a "forced unwind" (from the Itanium spec and from... something else I just read today or yesterday... LLVM manual, I think?)</p>



<a name="185065847"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065847" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065847">(Jan 07 2020 at 23:24)</a>:</h4>
<p>is that no language can stop the exception</p>



<a name="185065849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065849">(Jan 07 2020 at 23:24)</a>:</h4>
<p>so in those cses an abort is preferred to UB, though we may not be able to amnage one</p>



<a name="185065866"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065866" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065866">(Jan 07 2020 at 23:24)</a>:</h4>
<p>hmmm</p>



<a name="185065877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065877">(Jan 07 2020 at 23:24)</a>:</h4>
<p>I would think that in the <code>longjmp</code> case, not running dtors would be preferred!</p>



<a name="185065878"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065878" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065878">(Jan 07 2020 at 23:24)</a>:</h4>
<p>Not that it would be sound</p>



<a name="185065883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065883">(Jan 07 2020 at 23:25)</a>:</h4>
<p>But that it's what users of <code>longjmp</code> would expect.</p>



<a name="185065902"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185065902" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185065902">(Jan 07 2020 at 23:25)</a>:</h4>
<p>Possibly-irrelevant question: are C++ destructors expected to run when <code>pthread_exit</code> runs?</p>



<a name="185066012"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066012" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066012">(Jan 07 2020 at 23:27)</a>:</h4>
<p>it's UB is the point</p>



<a name="185066015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066015">(Jan 07 2020 at 23:27)</a>:</h4>
<p>rust programs are allowed to assume their dtors run</p>



<a name="185066021"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066021" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066021">(Jan 07 2020 at 23:27)</a>:</h4>
<p>many abstractions rely on this</p>



<a name="185066025"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066025" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066025">(Jan 07 2020 at 23:27)</a>:</h4>
<p>I know, but it's the same in C++, except moreso.</p>



<a name="185066072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066072">(Jan 07 2020 at 23:28)</a>:</h4>
<p>OK:)</p>



<a name="185066074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066074">(Jan 07 2020 at 23:28)</a>:</h4>
<p>I.e. the C++ community will tell you that "destructors always run"</p>



<a name="185066094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066094">(Jan 07 2020 at 23:28)</a>:</h4>
<p>there is no concept of something like <code>mem::forget</code> in C++</p>



<a name="185066096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066096">(Jan 07 2020 at 23:28)</a>:</h4>
<p>I believe in C++ it is UB to longjmp over a frame w/ dtors</p>



<a name="185066098"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066098" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066098">(Jan 07 2020 at 23:28)</a>:</h4>
<p>in any case</p>



<a name="185066106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066106">(Jan 07 2020 at 23:28)</a>:</h4>
<p>(but in windows, it is defined to run those dtors)</p>



<a name="185066121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066121">(Jan 07 2020 at 23:29)</a>:</h4>
<p>I think you're right, though Windows says "it may run dtors, it may not, depends on the optimizer"</p>



<a name="185066127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066127">(Jan 07 2020 at 23:29)</a>:</h4>
<p>which is why I think that system users would expect UB rather than abort logic</p>



<a name="185066142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066142">(Jan 07 2020 at 23:29)</a>:</h4>
<p>I guess.. I odn't care?</p>



<a name="185066145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066145">(Jan 07 2020 at 23:29)</a>:</h4>
<p>like, if it is UB</p>



<a name="185066152"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066152" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066152">(Jan 07 2020 at 23:29)</a>:</h4>
<p>Where "system users" means "programmers used to the way longjmp interacts with other languages that have 'drop'-like features"</p>



<a name="185066154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066154">(Jan 07 2020 at 23:29)</a>:</h4>
<p>then aborting is certain one possible thing :)</p>



<a name="185066163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066163">(Jan 07 2020 at 23:29)</a>:</h4>
<p>That's fair.</p>



<a name="185066167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066167">(Jan 07 2020 at 23:30)</a>:</h4>
<blockquote>
<p>Where "system users" means "programmers used to the way longjmp interacts with other languages that have 'drop'-like features"</p>
</blockquote>
<p>my point is: they should not be combining it</p>



<a name="185066218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066218">(Jan 07 2020 at 23:30)</a>:</h4>
<p>that is, they may <em>think</em> longjmp should 'just ignore' dtors</p>



<a name="185066220"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066220" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066220">(Jan 07 2020 at 23:30)</a>:</h4>
<p>but they are wrong :)</p>



<a name="185066228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066228">(Jan 07 2020 at 23:30)</a>:</h4>
<p>even though it might <em>look</em> like this is what happens</p>



<a name="185066258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066258">(Jan 07 2020 at 23:31)</a>:</h4>
<p>but I think this is a bit off topic I guess</p>



<a name="185066261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066261">(Jan 07 2020 at 23:31)</a>:</h4>
<p>and i'm cooking so I should stop :)</p>



<a name="185066264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066264">(Jan 07 2020 at 23:31)</a>:</h4>
<p>main thing I was thinking is:</p>



<a name="185066273"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066273" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066273">(Jan 07 2020 at 23:31)</a>:</h4>
<p>one advantage of "C unwind" is that it lets you identify call sites where unwinding is "important"</p>



<a name="185066686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066686">(Jan 07 2020 at 23:37)</a>:</h4>
<p>True... it just doesn't seem correct to me to put that information in the ABI.</p>



<a name="185066763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185066763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185066763">(Jan 07 2020 at 23:38)</a>:</h4>
<p>Backing up to the longjmp-over-Rust question: in <code>panic=abort</code> mode, on Windows, would you expect longjmp to be allowed over "inert" frames (as you termed them in your draft)?</p>



<a name="185067064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067064">(Jan 07 2020 at 23:43)</a>:</h4>
<p>A good question. I was assuming yes</p>



<a name="185067068"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067068" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067068">(Jan 07 2020 at 23:43)</a>:</h4>
<p>I think that is an explicit goal, in fact, no?</p>



<a name="185067075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067075">(Jan 07 2020 at 23:43)</a>:</h4>
<p>well, maybe not</p>



<a name="185067126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067126">(Jan 07 2020 at 23:44)</a>:</h4>
<p>we were trying to insert abort shims, but I guess those were triggering both with <code>-Cpanic=abort</code> and <code>-Cpanic=unwind</code>?</p>



<a name="185067715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067715">(Jan 07 2020 at 23:53)</a>:</h4>
<p>I was also assuming yes.</p>



<a name="185067992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185067992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185067992">(Jan 07 2020 at 23:58)</a>:</h4>
<p>somehow i feel more confused than I felt before:)</p>



<a name="185154206"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185154206" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185154206">(Jan 08 2020 at 20:38)</a>:</h4>
<p>Okay, so, if <code>-Cpanic=abort</code> only triggers abort on forced-unwind for debug builds when the unwind hits a _non-inert_ frame, I think that's reasonable.</p>



<a name="185154235"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185154235" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185154235">(Jan 08 2020 at 20:38)</a>:</h4>
<p>In release builds, UB, but again only for non-inert frames</p>



<a name="185154269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185154269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185154269">(Jan 08 2020 at 20:39)</a>:</h4>
<p>(Where "forced unwind" is defined by Itanium ABI and by LLVM, and the two most common instances are<code>pthread_exit</code> on <em>N</em>X platforms or <code>longjmp</code> on Windows)</p>



<a name="185154362"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185154362" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185154362">(Jan 08 2020 at 20:40)</a>:</h4>
<p>For inert frames, my inclination is to say that any interaction with a forced unwind is a violation of both LLVM's and Itanium's requirements for how language runtimes behave.</p>



<a name="185154380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185154380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185154380">(Jan 08 2020 at 20:40)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="143274">@Amanieu</span> does that seem correct?</p>



<a name="185155824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/185155824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#185155824">(Jan 08 2020 at 20:56)</a>:</h4>
<p>For inert frames we just let the unwind go through without touching it, yes.</p>



<a name="189058443"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189058443" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189058443">(Feb 25 2020 at 20:35)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> <span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think we should add a sentence explicitly mentioning <code>catch_unwind</code>; here's an update to the draft: <a href="https://github.com/rust-lang/project-ffi-unwind/pull/26" target="_blank" title="https://github.com/rust-lang/project-ffi-unwind/pull/26">https://github.com/rust-lang/project-ffi-unwind/pull/26</a></p>



<a name="189058475"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189058475" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189058475">(Feb 25 2020 at 20:35)</a>:</h4>
<p>After that,  I think we can publish the blog post as soon as we have a date for the meeting. Agreed? (Niko, it looks like you're back in the US?)</p>



<a name="189124807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189124807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189124807">(Feb 26 2020 at 15:32)</a>:</h4>
<p>I'm around now, yes,</p>



<a name="189124814"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189124814" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189124814">(Feb 26 2020 at 15:32)</a>:</h4>
<p>I'm in favor of posting the blog post --</p>



<a name="189124820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189124820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189124820">(Feb 26 2020 at 15:33)</a>:</h4>
<p>although I still feel like there's some "higher level" analysis that makes sense</p>



<a name="189124829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189124829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189124829">(Feb 26 2020 at 15:33)</a>:</h4>
<p>but I think we should post the post now :)</p>



<a name="189124845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189124845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189124845">(Feb 26 2020 at 15:33)</a>:</h4>
<p>did you want to open a PR against <a href="http://blog.rust-lang.org" target="_blank" title="http://blog.rust-lang.org">blog.rust-lang.org</a>, <span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span>?</p>



<a name="189126242"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189126242" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189126242">(Feb 26 2020 at 15:47)</a>:</h4>
<p>Sure; should we just pick a date?</p>



<a name="189126288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189126288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189126288">(Feb 26 2020 at 15:47)</a>:</h4>
<p><span class="user-mention" data-user-id="237472">@acfoltzer</span> did you see the doodle for rescheduling? <a href="https://doodle.com/poll/d9xevh43spf6rx8n#table" target="_blank" title="https://doodle.com/poll/d9xevh43spf6rx8n#table">https://doodle.com/poll/d9xevh43spf6rx8n#table</a></p>



<a name="189127715"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189127715" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189127715">(Feb 26 2020 at 16:01)</a>:</h4>
<p>Amanieu isn't available on the 9th, so let's pick either the 2nd or the 16th</p>



<a name="189132015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189132015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> acfoltzer <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189132015">(Feb 26 2020 at 16:42)</a>:</h4>
<p>hey, thank you. my Zulip tab got unloaded and didn't see the messages</p>



<a name="189141130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189141130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189141130">(Feb 26 2020 at 18:13)</a>:</h4>
<p><a href="https://github.com/rust-lang/blog.rust-lang.org/pull/522" target="_blank" title="https://github.com/rust-lang/blog.rust-lang.org/pull/522">https://github.com/rust-lang/blog.rust-lang.org/pull/522</a></p>



<a name="189141256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189141256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189141256">(Feb 26 2020 at 18:15)</a>:</h4>
<p>Okay, I'm assuming that the lang team members can make any of the four dates, since the design meetings are recurring. (Niko, please let me know if this isn't the case!) Since the rest of us are available this Monday, shall we just go ahead with that as the proposed date?</p>



<a name="189143264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189143264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189143264">(Feb 26 2020 at 18:32)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> It seems the markdown support is different for <code>blog.rust-lang.org</code> than for GitHub. The table does not render correctly.</p>



<a name="189146256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189146256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189146256">(Feb 26 2020 at 18:57)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span> I just noticed that we no longer have any <code>UB (debug: abort)</code> entries in the table.</p>



<a name="189146276"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189146276" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189146276">(Feb 26 2020 at 18:57)</a>:</h4>
<p>Yet we still have a sentence talking about them.</p>



<a name="189146368"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189146368" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189146368">(Feb 26 2020 at 18:58)</a>:</h4>
<p>Let's take discussion about the draft to the PR I've opened: <a href="https://github.com/rust-lang/blog.rust-lang.org/pull/522" target="_blank" title="https://github.com/rust-lang/blog.rust-lang.org/pull/522">https://github.com/rust-lang/blog.rust-lang.org/pull/522</a></p>



<a name="189149452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189149452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189149452">(Feb 26 2020 at 19:26)</a>:</h4>
<p><span class="user-mention" data-user-id="143274">@Amanieu</span> I've pushed an update to discuss the "UB (debug: abort)" possibility without actually modifying the table entries</p>



<a name="189149552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189149552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189149552">(Feb 26 2020 at 19:27)</a>:</h4>
<p>LGTM</p>



<a name="189158326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189158326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189158326">(Feb 26 2020 at 20:59)</a>:</h4>
<p><span class="user-group-mention" data-user-group-id="1866">@WG-ffi-unwind</span>  I'm going to go ahead and put 2020-03-02  as the date of the upcoming meeting unless someone objects.</p>



<a name="189378932"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189378932" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189378932">(Feb 29 2020 at 06:29)</a>:</h4>
<p>Hello,</p>
<p>I've read the blogpost and unfortunately I'm unable to attend the upcoming meeting. I have a cross-platform (windows/linux), ffi heavy project that run into this as the the C code uses longjmp across rust frames. In the common case my stack frames look something like: Rust -&gt; C -&gt; extern "C" Rust -&gt; Rust -&gt; C longjmp back to top first C frame.</p>
<p>I have two specific questions:</p>
<ul>
<li>There are no options where forced unwinding results in destructors being run if panic=abort. I presume there is some technical limitation which prevents this from being feasible?</li>
<li>For unwinding across rust frames, would all frames need to be tagged with some extern definition? I.e. would the inner rust frame in my layout be ok?</li>
</ul>
<p>FWIW based on what I've read so far, my preference would be proposal <a href="https://github.com/rust-lang/rust/issues/3" target="_blank" title="https://github.com/rust-lang/rust/issues/3">#3</a>, with some sort of pragma to warm/disallow -C panic=abort.</p>



<a name="189382600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189382600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189382600">(Feb 29 2020 at 08:49)</a>:</h4>
<p>these Rust frames, do you control them (and the drop types that are owned by them), or could they be arbitrary user frames?<br>
with arbitrary user frames I'm afraid this is unsound and there is no fix. you cannot have unsafe code deallocate memory without running drop unless every single drop function that is being skipped has been carefully vetted to be okay with that -- which is of course impossible when, in generic or higher-order code, you cannot tell which types' drops are being skipped.</p>



<a name="189383382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189383382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189383382">(Feb 29 2020 at 09:16)</a>:</h4>
<p><span class="user-mention" data-user-id="252303">@pquux</span> First of all, keep in mind that longjmp is UB if you skip over any frames with destructors in them. If you really want to have destructors run then you need to use a different mechanism for unwinding, such as a C++ exception or a Rust panic.</p>



<a name="189383432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189383432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189383432">(Feb 29 2020 at 09:18)</a>:</h4>
<p>Regarding your questions:</p>
<ul>
<li>Under <code>panic=abort </code> we don't emit any unwinding information to reduce binary size. That is after all the main point of <code>panic=abort</code>. So it is impossible for destructors to run when unwinding.</li>
<li>Only the outermost frame (the one that interacts with C code) would need to be <code>extern "C"</code> or <code>extern "C unwind"</code>.</li>
</ul>



<a name="189406961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189406961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189406961">(Feb 29 2020 at 21:52)</a>:</h4>
<p>@RalfJ I sadly do not control them, the idea of the project is to allow users to write rust code as a library that interacts with the C code.</p>
<p>@Amanieu Perhaps my understanding of unwinding is wrong, but what do you mean by "skip over any frames with destructors in them"? My understanding is fairly naive, but conceptually involves walking all stack frames between where you're throwing/longjmping from and the dest. I understand that on x64 they use unwind tables for this (as opposed to frame pointers). Does this mean some frames might not have unwind info, and longjmping over them is UB as they wouldnt be destructed properly?</p>
<p>Unfortunately the longjmp is somewhat out of my control. I can modify the C code Im ffi'ing to, but it's use of longjmp is pretty foundational to the rest of the codebase and I don't trust myself enough to modify it in such an invasive way.</p>
<p>What it sounds like is that regardless of which solution is chosen I'll still be in UB territory, but I'm not any better or worse off than I would be with equivalent C/C++ code. Apologies if this is the wrong forum for these questions, and thank you both for taking the time to reply.</p>



<a name="189408676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189408676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189408676">(Feb 29 2020 at 22:49)</a>:</h4>
<p><span class="user-mention" data-user-id="252303">@pquux</span> <code>longjmp</code> on Windows uses unwinding. On all other platforms it just skips straight to the <code>setjmp</code> by restoring the stack pointer value at the <code>setjmp</code> call. In both cases there must be no destructors in the frames being skipped.</p>



<a name="189408686"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189408686" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189408686">(Feb 29 2020 at 22:49)</a>:</h4>
<p>Are you using lua by any chance?</p>



<a name="189409048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409048">(Feb 29 2020 at 23:01)</a>:</h4>
<p>Nope, its a fairly well tested emulator for a complicated ISA. Im aware of the platform difference there, but sorry, I still dont understand what you mean by frames being skipped.</p>



<a name="189409103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409103">(Feb 29 2020 at 23:02)</a>:</h4>
<p><a href="https://en.cppreference.com/w/cpp/utility/program/longjmp" target="_blank" title="https://en.cppreference.com/w/cpp/utility/program/longjmp">https://en.cppreference.com/w/cpp/utility/program/longjmp</a></p>



<a name="189409104"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409104" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409104">(Feb 29 2020 at 23:02)</a>:</h4>
<p>Also just to be clear, what I have seems to work on both linux and windows, Im more trying to figure out how thin the ice I'm on is, and if there are things I can do to make it less thin.</p>



<a name="189409107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409107">(Feb 29 2020 at 23:02)</a>:</h4>
<blockquote>
<p>No destructors for automatic objects are called. If replacing of std::longjmp with throw and setjmp with catch would execute a non-trivial destructor for any automatic object, the behavior of such std::longjmp is undefined.</p>
</blockquote>



<a name="189409164"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409164" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409164">(Feb 29 2020 at 23:04)</a>:</h4>
<p>What I mean by frames being skipped is something like this:<br>
C ==calls=&gt; Rust ==calls=&gt; C ==calls=&gt; longjmp</p>



<a name="189409176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409176">(Feb 29 2020 at 23:04)</a>:</h4>
<p>Where the longjmp skips over the Rust frames and goes straight back to the first C frrame.</p>



<a name="189409249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409249">(Feb 29 2020 at 23:07)</a>:</h4>
<p>oh, duh. Im sorry, I see now. I mostly develop on windows and had internalized their longjmp/unwinding.</p>



<a name="189409292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409292">(Feb 29 2020 at 23:08)</a>:</h4>
<p>Does the pattern I showed represent what your code is doing?</p>



<a name="189409311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189409311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189409311">(Feb 29 2020 at 23:09)</a>:</h4>
<p>Yes.</p>
<p>So basically my options are:</p>
<ul>
<li>explore not use longjmp and replace it with a panic/catch, keep it in rustland the entire time</li>
<li>continue using longjmp, document that the middle skipped frames do not have destructors run<ul>
<li>this means the linux/windows behavior potentially vary, based on compiler flags</li>
</ul>
</li>
</ul>



<a name="189410020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189410020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189410020">(Feb 29 2020 at 23:32)</a>:</h4>
<p>Option 2 needs to be stronger: you CANNOT have destructors, otherwise behavior is undefined.</p>



<a name="189410036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189410036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189410036">(Feb 29 2020 at 23:32)</a>:</h4>
<p>For option 1, you can use C++ exceptions as one possible alternative.</p>



<a name="189410048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189410048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189410048">(Feb 29 2020 at 23:33)</a>:</h4>
<p>C++ exceptions and Rust panics would be more or less equivalent for your purposes: they both provide a well-defined way of running destructors while unwinding.</p>



<a name="189410093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189410093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189410093">(Feb 29 2020 at 23:34)</a>:</h4>
<p>(FWIW the UB in option 2 would also have applied in the same way if you had used C++ instead of Rust)</p>



<a name="189410350"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189410350" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189410350">(Feb 29 2020 at 23:43)</a>:</h4>
<p>For option 2, it may be conceptually easier to limit the local types used in intermediate frames to <code>Copy</code> types. Non-<code>Drop</code> is a strictly weaker requirement than <code>Copy</code>, but harder to express in code.</p>



<a name="189411975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189411975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189411975">(Mar 01 2020 at 00:34)</a>:</h4>
<p>Yeah, Im in the same boat I'd be in without rust, just more aware of it.</p>
<p>Alright, I appreciate the details and the assistance :) good luck with your meeting</p>



<a name="189411985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189411985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pquux <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189411985">(Mar 01 2020 at 00:34)</a>:</h4>
<p>If I can be helpful in any way with an example use case, please feel free to reach out.</p>



<a name="189416775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189416775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189416775">(Mar 01 2020 at 03:11)</a>:</h4>
<p>Thanks!</p>



<a name="189416776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189416776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189416776">(Mar 01 2020 at 03:11)</a>:</h4>
<p>Thanks!</p>



<a name="189416822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189416822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189416822">(Mar 01 2020 at 03:12)</a>:</h4>
<p>There should be some C libraries that can initiate and halt unwinding. I'm having a bit of trouble finding a well-documented one, though.</p>



<a name="189416829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189416829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189416829">(Mar 01 2020 at 03:13)</a>:</h4>
<p>(for option 1)</p>



<a name="189442365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189442365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189442365">(Mar 01 2020 at 18:19)</a>:</h4>
<p><span class="user-mention silent" data-user-id="120076">BatmanAoD (Kyle Strand)</span> <a href="#narrow/stream/210922-project-ffi-unwind/topic/Blog.20post/near/189410350" title="#narrow/stream/210922-project-ffi-unwind/topic/Blog.20post/near/189410350">said</a>:</p>
<blockquote>
<p>For option 2, it may be conceptually easier to limit the local types used in intermediate frames to <code>Copy</code> types. Non-<code>Drop</code> is a strictly weaker requirement than <code>Copy</code>, but harder to express in code.</p>
</blockquote>
<p><span class="user-mention" data-user-id="252303">@pquux</span> said above there are user-controlled frames in there, in which case such a limit couldn't be enforced</p>



<a name="189442379"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189442379" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189442379">(Mar 01 2020 at 18:19)</a>:</h4>
<p>under that constraint, I don't think it is possible to have a safe interface -- if someone combines your library with, say, rayon, they could use that to break safety in safe code.</p>



<a name="189442801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/189442801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#189442801">(Mar 01 2020 at 18:31)</a>:</h4>
<p>Yes, that's certainly true. I'm just suggesting that "only use <code>Copy</code> types" is a decent way to express the restriction to users.</p>



<a name="223574269"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223574269" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223574269">(Jan 21 2021 at 21:39)</a>:</h4>
<p>Thanks for approving the PR, <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ! I did see the build failure; I expect it's because I didn't put a real date in the date field. Should I set it to today?</p>



<a name="223574387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223574387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223574387">(Jan 21 2021 at 21:40)</a>:</h4>
<p>Or rather, I didn't put a real date in the title.</p>



<a name="223575135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223575135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223575135">(Jan 21 2021 at 21:47)</a>:</h4>
<p>Looking at the nit, I'm not sure the "infinite loop" phrase is actually helpful. The point is just that <code>-&gt; !</code> functions still enforce standard RAII resource-cleanup when necessary, so non-POFs can be used.</p>



<a name="223575316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223575316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223575316">(Jan 21 2021 at 21:48)</a>:</h4>
<p>It's possible we should just take the section out entirely. I may be the only person making a mental connection to the "never" return type anyway.</p>



<a name="223578992"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223578992" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223578992">(Jan 21 2021 at 22:18)</a>:</h4>
<p>Yeah, that may be</p>



<a name="223580102"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223580102" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223580102">(Jan 21 2021 at 22:28)</a>:</h4>
<p>Okay, I've fixed the build by setting the date to today and removed that section. Shall I merge if the final CI check passes?</p>



<a name="223581604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/223581604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#223581604">(Jan 21 2021 at 22:42)</a>:</h4>
<p>Oh, never mind, I can't merge on my own. Anyway, the checks have passed.</p>



<a name="224042988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224042988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224042988">(Jan 26 2021 at 14:07)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span> merged!</p>



<a name="224042996"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224042996" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224042996">(Jan 26 2021 at 14:07)</a>:</h4>
<p>sorry for the delay</p>



<a name="224044982"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224044982" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224044982">(Jan 26 2021 at 14:21)</a>:</h4>
<p>No problem; thanks!</p>



<a name="224046366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224046366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224046366">(Jan 26 2021 at 14:30)</a>:</h4>
<p><a href="/user_uploads/4715/Jel7BWitsVBXphnAwdyUFBrk/Screenshot_20210126-073006.jpg">Screenshot_20210126-073006.jpg</a></p>
<div class="message_inline_image"><a href="/user_uploads/4715/Jel7BWitsVBXphnAwdyUFBrk/Screenshot_20210126-073006.jpg" title="Screenshot_20210126-073006.jpg"><img src="/user_uploads/4715/Jel7BWitsVBXphnAwdyUFBrk/Screenshot_20210126-073006.jpg"></a></div>



<a name="224046380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224046380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224046380">(Jan 26 2021 at 14:30)</a>:</h4>
<p>That's weird...</p>



<a name="224056147"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224056147" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224056147">(Jan 26 2021 at 15:36)</a>:</h4>
<p>hmmm</p>



<a name="224056256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224056256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224056256">(Jan 26 2021 at 15:37)</a>:</h4>
<p><span class="user-mention" data-user-id="120076">@BatmanAoD (Kyle Strand)</span> I didn't notice this, but</p>
<blockquote>
<p>author: Kyle Strand on behalf of the FFI-unwind project group </p>
</blockquote>
<p>should just be 'Kyle Strand' :)</p>



<a name="224062587"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224062587" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224062587">(Jan 26 2021 at 16:14)</a>:</h4>
<p>Ah, that makes sense</p>



<a name="224062617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224062617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224062617">(Jan 26 2021 at 16:15)</a>:</h4>
<p>Does the date in the file name matter?</p>



<a name="224062815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224062815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224062815">(Jan 26 2021 at 16:16)</a>:</h4>
<p>Oh, I see you renamed it before merging! Thanks.</p>



<a name="224063070"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224063070" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224063070">(Jan 26 2021 at 16:18)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/rust-lang/blog.rust-lang.org/pull/770">https://github.com/rust-lang/blog.rust-lang.org/pull/770</a></p>



<a name="224065898"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224065898" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224065898">(Jan 26 2021 at 16:36)</a>:</h4>
<p>merged</p>



<a name="224071051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/210922-project-ffi-unwind/topic/Blog%20Post/near/224071051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> BatmanAoD (Kyle Strand) <a href="https://rust-lang.github.io/zulip_archive/stream/210922-project-ffi-unwind/topic/Blog.20Post.html#224071051">(Jan 26 2021 at 17:11)</a>:</h4>
<p>Thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>